<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="produce_device" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="i_product('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/mes/quality/CartogramTestingDevice?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 检验设备 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="分类" prop="menu_class">
              <el-radio-group v-model="produce_device.menu_class">
                <el-radio-button label="检测设备">检测设备</el-radio-button>
                <el-radio-button label="检测器具">检测器具</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="条形码" prop="produce_barcode">
              <el-input v-model="produce_device.produce_barcode" readonly />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备名称" prop="produce_name">
              <el-input v-model="produce_device.produce_name" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备型号" prop="produce_model">
              <el-input v-model="produce_device.produce_model" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备规格" prop="produce_norm">
              <el-input v-model="produce_device.produce_norm" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="供应商" prop="client_id">
              <el-select style='width:100%' v-model="produce_device.client_id" @change="list_s_sname">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_sname" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-button @click="gotoPage('BFDF389BA10D4E75954B1E7D834D21BA?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加供应商</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="制造商" prop="produce_maker">
              <el-select style='width:100%' v-model="produce_device.produce_maker">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_mname" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="检测设备分类" prop="menu_class">
              <el-select style='width:100%' v-model="produce_device.menu_class">
                <el-option label="测量工具" value="测量工具" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 附加说明 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="简短描述" prop="produce_simdescribe">
              <el-input v-model="produce_device.produce_simdescribe" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="具体描述" prop="produce_describe">
              <el-input type="textarea" v-model="produce_device.produce_describe" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="i_product('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/mes/quality/CartogramTestingDevice?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'CheckDevNoteNAdd',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        produce_device: {
          menu_class: null,
          produce_barcode: null,
          produce_name: null,
          produce_model: null,
          produce_norm: null,
          client_id: null,
          produce_maker: null,
          menu_class: null,
          produce_simdescribe: null,
          produce_describe: null,
        },
        s_sname: [],
        s_mname: [],
        loading: false,
        rules: {
          produce_name: [{
            required: true,
            message: "设备名称不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/quality/TestingDeviceAction/checkDevNoteNAdd?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      i_product(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/quality/TestingDeviceAction/i_product?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/produce/DetectionDevDet/detectionDevDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      list_s_sname(value) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/quality/TestingDeviceAction/ajaxList?' + this.vueparams,
          params: {
            htmltable: '',
            cfield_name: "product_info",
            client_id: value
          }
        }).then(data => {})
      },
    },
  }
</script>
